package com.bauer.java.spring.web;

import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @Author ：rui.wei
 * @Date ：Created in 15:05 2019/4/18
 * @Description：
 */
@org.springframework.web.bind.annotation.RestControllerAdvice
public class ControllerAdvice {

    @ExceptionHandler(MethodArgumentNotValidException.class)
    public Object handle(MethodArgumentNotValidException ex) {
        System.out.println(ex.getBindingResult().getAllErrors().get(0).getDefaultMessage());
        return "hello";
    }
}
